<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<body>
	<ui:composition template="/pages/protected/user/default.xhtml">
		<ui:define name="content">

			<h3>${msgs.transactionCreateHeader}</h3>
			
			<h4><h:outputLabel value="#{msgs.createCategoryFirst}" rendered="#{empty categoryMB.allCategories}" /></h4>

			<h:form id="transaction" rendered="#{not empty categoryMB.allCategories}">
				<h:panelGrid columns="2" styleClass="panelGrid"
					rowClasses="panelOddLine,panelEvenLine">

					<h:outputLabel for="listbox" value="#{msgs.category} :" />
					<h:selectOneMenu id="listbox"
						converter="#{categoryConverterBean}"
						value="#{transactionMB.transaction.category}">
						<f:selectItems value="#{categoryMB.allCategories}"
							var="category" itemLabel="#{category.name}" itemValue="#{category}"
							 />
					</h:selectOneMenu>

					<h:outputLabel for="calendar" value="#{msgs.date} :" />
					<p:calendar value="#{transactionMB.transaction.date}" id="calendar"
						pattern="yyyy. MM. dd." />


					<h:outputLabel for="amount" value="#{msgs.amount} (HUF) :" />
					<h:inputText id="amount" required="true"
						requiredMessage="#{msgs.amountNameRequired}"
						value="#{transactionMB.transaction.amount}">
						<f:validateDoubleRange minimum="0.0000001" />
					</h:inputText>

					<h:outputLabel for="listbox" value="#{msgs.type} :" />
					<h:selectOneMenu id="type" value="#{transactionMB.transaction.type}">
						<f:selectItem itemLabel="#{msgs.income}" itemValue="1" />
						<f:selectItem itemLabel="#{msgs.outgo}" itemValue="-1" />
					</h:selectOneMenu>
					
					<h:outputLabel for="listbox" value="#{msgs.note} :" />
					<h:inputText id="note" value="#{transactionMB.transaction.note}"/>
					
					
				</h:panelGrid>
				
				<h:panelGrid columns="2">
				<h:link outcome="listTransactions" value="#{msgs.cancel}"
						immediate="true" />
					<h:commandButton action="#{transactionMB.createTransaction()}"
						value="#{msgs.create}" />
				</h:panelGrid>
					
				</h:form>
		</ui:define>
	</ui:composition>
</body>
</html>